#!/bin/bash

OLDIFS=$IFS

IFS=$'\n'

me=`basename $0`

targets=($(ps -eo pid,comm,command | grep $1 | grep -v $me | grep -v grep))

if [ ${#targets[@]} -gt 1 ]; then
    for line in ${targets[@]}; do
        echo $line
    done
else
    echo -e "killing ==> \n$targets"
    pid=$(echo $targets | awk '{print $1}')
    kill -9 $pid
fi

IFS=$OLDIFS
